﻿Japan Pro Golf Tour 64 DLC Uploader

  Wikipedia is full of lies.

  This 64DD title does not use a modem and did not have online play.  Network tournaments were password powered, not head-to-head.  However, it did have one amazing feature via Randnet that went completely unused and undocumented: downloadable content.

  You would (presumably) go to the page for it on Randnet, dole out your offering, stick your disk in at a prompt, and they would write the update to a very specific LBA.  When you run the game the next time, this data is unpacked into your MFS RAM save directory and is available for use from then onward.
  The game is rather selective about what it will read from saved data, but there's one thing in particular it was designed to do: add additional courses.

  This, cousins, is why the game couldn't be pushed onto a cartridge.  Upward of ~17MB of additional courses could be downloaded and added to your disk (likely at sizable expense, DLC being DLC).  The feature is fully implemented, you just need to stick correctly-formatted data in the right place.  If you have a spare bar of gold, buy one of these rare lovelies, and have a flashcart that plays nice with the 64DD you can feed it new courses!  No development drive required, and none of the original courses are replaced.  After loading them once they're permanently available, even without a flashcart.

  That said, it also works swimmingly with dev drives, even those lacking an internal IPL.  In addition, because it's implemented as a cartridge expansion for the disk game it's also usable with any emulators that support booting disks and carts simultaneously.  Simply feed it the disk and the cart and it patches just as if you used it on console.  Huzzah!

  Another advantage to using this splendid cartridge expansion is it patches away two of the biggest limitations in the original DLC update implementation.  It no longer spins endlessly if you feed it the same update twice, and it appends, not replaces, the course list.  As a bonus, it can also take more than one package at a time.  Each package still has the limit of 3MB, but course files can contain multiple packages, effectively removing the filesize limit altogether.  You are only limited by disk space.

  Use this once to patch your game, and you can continue playing if you like.  For later sessions it's suggested to simply play the disk on its own, if only so it doesn't waste time repatching your game needlessly.

  ...and too bad for those hapless fools using diskcart conversions or original Partner64 setups.  You simply aren't supported; one badly-structured file or user-omitted entry could render your ROM/disk unusable, and end users are never to be trusted.  There's always emulation ;*)


.: Usage :.
  Simply append one or more of the course binaries to "stubbums.n64".  No special tool is needed to copy.  Even the old win command prompt method is fine, like so:
COPY /B stubbums.n64 + GolfdeBordeauxClub.crs + TokyoBayResort.crs combined.n64

  Linux users: you should already know the correct answer is cp else you shouldn't be using *nix.

  If you're using oldskool dev hardware, send the update binaries starting at 0x170000.  Yes yes yes, it's not the "standard" 2MB offset.  Sorry ;)

  Once the appended ROM is created, either place it on any flashcart or use it in the "cart" slot of an emulator.  The Japan Pro Golf Tour 64 disk needs to be in the drive, emulated or physical.  When run, the update will be written to the disk and a progress bar is displayed.  If more than one course is being added, each receives a new progress bar.


.: Courses :.
  As there's no point releasing a course uploader without something to upload, courses from SeTa's N64 & PSX Eikou no St. Andrews titles were up-ported to the 64DD.  Objects and textures were replaced as best-fit as possible, based more on size and collidability than type.

  Seasonal textures are supported in the SeTa original courses: Golf de Bordeaux Club, Dog Hill Golf & Country Club, Lakewoods Golf Club, Montreal Golf Course, and Tokyo Bay Resort.  The current season can be switched in the options menu.
  None of the five original PSX courses had Japanese hole introductions so don't be surprised when you don't see them.
  Out-of-bound areas are preserved.  The strange "mid-fairway" holes on the five original courses have been removed and different handicap tee boxes linked when available.  Minimaps for the greens have been reused despite the stylistic difference, but almost all minimaps for holes are new captures.  Fairway maps (shown within ~95yds of the hole) have been added for par 4 & 5 holes.


.! Horrible Caveat Section !.
  None of the network features were very well debugged before the game was pushed out the door to the few people who preordered it.  [Stubbums] circumvents most of these, but for completeness here's a list of all the possible issues that could occur during updates.

*) From the factory, disks contained a file called "zero3MByte.dat", saved to LBA 0CC2/0CDA (+0x2F0 from the start of the MFS RAM table).  If you've ever reinitialized your save (hold C Up + C Down + C Left + C Right while transitioning from legal to intro attract) it should be fine, but if it had to be reformatted due to corruption this file was not created.
   As it turns out, that file is a placeholder for DLC updates (DDWRTR.BIN).  If you don't have it, there's the possibility that the game will attempt to save the downloaded data right over itself, and you won't be able to load more without corrupting what already exists--if it doesn't crash or something in the process.
   This thing *should* check the MFS directory and make sure it isn't saving over something that exists, but there is the possibility something horrible happens and everything get reformatted.
   Note that a reformat doesn't stop a DLC update from occurring.  The LBA itself is read, without regards to the filesystem.
*) There's no built-in capacity to delete anything outside reformatting your entire MFS directory.  Overwriting of files is possible, but not deletion.
*) Creating a directory that already exists will softlock the game.  This is particularly annoying since adding courses requires creating directories and there's no capacity to remove them.  As such, don't try to upload a course you already have unless you're using [stubbums].  If you do, you'll need to overwrite the update to proceed.
*) The last file or directory written to a non-root directory will not have its filesize or address set due to a bug.  Therefore, you always need to push a blank, zero-size file after the last file written to a directory.
*) Save files are extended from their original size by the number of additional courses you have loaded.  However, if you replace an uploaded course with another, don't be surprised if save.dat or net.dat get confused.  If the save file is longer than the course list it will be assume it's corrupt and reformat it, which isn't exactly false since it can't determine how much data to decrypt otherwise.
   Saved games keep the ID of the course played and use it to reload that data, so attempting to load saved data for a course you removed is not recommended and likely will hang.  Likewise, it's a really good idea that courses don't recycle IDs.  There's 4999 available values and no room for excuses.
   One bug stubbums does introduce is making it impossible to add a course name entry to one that partially matches an existing entry.  As a result, you won't be able to replace the two commented-out viable filenames for the Practice Course and Test Course (5001 & 5116 respectively) without changing their Japanese names in some nominal way that prevents a substring match, like altering tab count.
*) Although the first 32 courses (10 + 22 imported) can be played in Network Tournament mode, there was no provision for extending the name and course pics shown on the confirmation screen beyond the original 10 courses.  However, once past this screen the tournament should proceed without any serious issues.
*) The course list is read a number of times at startup, but only the first list found will be used to generate the course list used.  First the RAM section is checked, and if not found the default one in ROM is used.  Clearly they intended to append it with new data but, unfortunately, that isn't the case.  Course lists are only replaced, not appended.
   With the maximum upload size fixed at 3MB, supporting multiple updates requires ripping any existing list, then appending it with new entries.  [Stubbums] does this, but in its original form you'd need the software providing the DLC to scan the RAM MFS directory to find any lists, append it, and add this file into the DLC pack it sends--all in HTML 1.0.  This is also the only safe way to support diskcarts, and at that point you might as well just write the data directly and circumvent any potential writeback issues.  In all honesty though, if they only planned to make a single update the issue would never arise in the first place.
*) Course textures are mapped dynamically at runtime based on their vertex positions.  It also generates detail texture UVs as tiles are being drawn, refreshing between vertex buffer assignments.  PSX courses were originally at half scale, and more importantly they draw geometry solely based on the collision data.  All of this is oriented sinister, and although they all should be facing the correct way now there's a chance that between the upscale, reorientation, and conversion to the scripting which dynamically generates the display lists that autotexturing doesn't always work correctly.  Oops?
*) Weighted vertex normals were used for smooth shading, but unfortunately due to vertex duplication and near-but-not-exact situations not all faces that should logically be shared actually are.  This affects the output, but it's nowhere near as terrible as averaging the original normals.  There's also a relative lack of contrast since, at half scale, PSX courses reduced away a significant amount of geometry that fell within too small a range of deviation and otherwise wasn't flagged (like greens), so surfaces like bunker edges may only be one or two faces before a flat bottom.  Face normals used for determining ball impact were not recalculated.


.: Data Format Notes :.
  This happens to push a few backward-compatible extensions for future translations.  This way a single file can be used across regions without localization issues.
*) Course lists now support specially-commented out entries for localized disk builds.  Use the disk GUID between hashes for name replacements in that language, ie. #DPGE# for the USA translation.  These lines are ignored by Japanese builds.
*) Translations will accept a localized hole introduction if you set the IFF tag to the GUID.  This overloads the normal 'intr' text so it must occur after that tag in the file.  It can also be included in a background node following the terrain node.
*) Overload the course and tournament select images by providing a map file with the two images, a placeholder entry, and the region code appended to the extension (.dat -> .datE).  Remember filenames are case sensitive!
*) Only course IDs whose first char is '5' (0x35) or over will be read from the RAM segment.  Unfortunately, that means the four sets of unused maps--4003, 4014, 4015, & 0116 (Taiheiyo Club Ichihara Course / 太平洋クラブ市原コース)--can't be used directly from the ROM segment.  Portions of the Japanese codebase anticipate a 4-digit number not exceeding 9999, so try to stay compatible.
*) There's no known method of utilizing B, C, D, etc. hole variants, though they are technically supported by the engine.  Multiple cups and tees on the same hole are supported though.

-Zoinkity
